From: Florian Müllner Date: Tue, 10 Jun 2025 01:11:05 +0000 (+0200) Subject: tools: Switch to flat config for eslint X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~116^2^2~34 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=90afcbf59826974f793fb599eb038021ee8b1927;p=gnome-shell.git tools: Switch to flat config for eslint Both the .json and .yml config formats are deprecated in favor of flat configs exported from eslint.config.js files. The good news is that gjs' config is now available as a shared config from the `eslint-config-gnome` package in World/javascript, so we no longer have to copy the entire thing. Part-of: --- diff --git a/eslint.config.js b/eslint.config.js new file mode 120000 index 000000000..8e6e2c0df --- /dev/null +++ b/eslint.config.js @@ -0,0 +1 @@ +tools/eslint.config.js \ No newline at end of file diff --git a/tools/eslint.config.js b/tools/eslint.config.js new file mode 100644 index 000000000..82b860911 --- /dev/null +++ b/tools/eslint.config.js @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: 2025 Florian Müllner +// SPDX-License-Identifier: MIT OR LGPL-2.1-or-later + +import {defineConfig} from '@eslint/config-helpers'; +import globals from 'globals'; +import gnome from 'eslint-config-gnome'; + +export default defineConfig([ + gnome.configs.recommended, + gnome.configs.jsdoc, + { + ignores: [ + '_build-*', + 'data', + 'docs', + 'man', + 'src', + 'subprojects/gvc', + 'subprojects/jasmine-gjs', + 'subprojects/libshew', + ], + }, { + rules: { + camelcase: ['error', { + properties: 'never', + }], + 'consistent-return': 'error', + 'eqeqeq': ['error', 'smart'], + 'key-spacing': ['error', { + mode: 'minimum', + beforeColon: false, + afterColon: true, + }], + 'prefer-arrow-callback': 'error', + 'jsdoc/require-param-description': 'off', + 'jsdoc/require-jsdoc': ['error', { + exemptEmptyFunctions: true, + publicOnly: { + esm: true, + }, + }], + }, + }, { + files: [ + 'js/**', + 'tests/shell/**', + ], + ignores: [ + 'js/portalHelper/*', + 'js/extensions/*', + ], + languageOptions: { + globals: { + global: 'readonly', + _: 'readonly', + C_: 'readonly', + N_: 'readonly', + ngettext: 'readonly', + }, + }, + }, { + files: ['tests/unit/**'], + rules: { + 'jsdoc/require-jsdoc': 'off', + }, + languageOptions: { + globals: { + ...globals.jasmine, + }, + }, + }, { + files: ['subprojects/extensions-app/js/**'], + languageOptions: { + globals: { + _: 'readonly', + C_: 'readonly', + N_: 'readonly', + }, + }, + }, +]); diff --git a/tools/package-lock.json b/tools/package-lock.json index 105bc1c4e..7e2fac923 100644 --- a/tools/package-lock.json +++ b/tools/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT OR LGPL-3.0-or-later", "dependencies": { "ci-run-eslint": "git+https://gitlab.gnome.org/World/javascript/ci-run-eslint.git", - "eslint-plugin-jsdoc": "^48.11.0" + "eslint-config-gnome": "git+https://gitlab.gnome.org/World/javascript/eslint-config-gnome.git" } }, "node_modules/@es-joy/jsdoccomment": { @@ -479,7 +479,7 @@ }, "node_modules/eslint-config-gnome": { "version": "1.0.0", - "resolved": "git+https://gitlab.gnome.org/World/javascript/eslint-config-gnome.git#bb86b2d6a4ef575e84d1374676aff0187cf3fedf", + "resolved": "git+https://gitlab.gnome.org/World/javascript/eslint-config-gnome.git#c479d059e8d9ea99c3b53c2ea43abf7fdb05eb51", "license": "MIT OR LGPL-2.1-or-later", "dependencies": { "@eslint/config-helpers": "^0.2.2", diff --git a/tools/package.json b/tools/package.json index 31d7d1d94..6d5a089b5 100644 --- a/tools/package.json +++ b/tools/package.json @@ -9,6 +9,6 @@ }, "dependencies": { "ci-run-eslint": "git+https://gitlab.gnome.org/World/javascript/ci-run-eslint.git", - "eslint-plugin-jsdoc": "^48.11.0" + "eslint-config-gnome": "git+https://gitlab.gnome.org/World/javascript/eslint-config-gnome.git" } }